package org.example.controller;

import org.example.dto.BusinessPageDto;
import org.example.result.PageResult;
import org.example.result.Result;
import org.example.service.BusinessService;
import org.example.vo.GoodsMaterialVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("product")
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    /**
     * 生产商列表
     * @return
     */
    @RequestMapping("businessList")
    public Result businessList(BusinessPageDto businessPageDto) {
        //列表分页
        PageResult pageResult = businessService.businessListAll(businessPageDto);
        return Result.success(pageResult);
    }

    /**
     * 根据生产商ID  张氏每个人的所属材料
     */
    @RequestMapping("materialList/{id}")
    public Result materialList(@PathVariable("id") String id) {
        List<GoodsMaterialVo> list = businessService.materialList(id);
        return Result.success(list);
    }
}
